package com.laiyizhan.cms.first.service.impl;

import com.laiyizhan.cms.first.request.LastFourRequest;
import com.laiyizhan.cms.first.service.ILastFourService;
import com.laiyizhan.common.mapper.*;
import com.laiyizhan.common.model.*;
import org.junit.rules.TestName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import static org.springframework.beans.BeanUtils.copyProperties;

/**
 * Created by SoulWolf on 2017/7/22.
 */
@Service
public class LastFourServiceImpl implements ILastFourService {

    @Autowired
    StateMapper stateMapper;
    @Autowired
    Eighth_messageMapper eighth_messageMapper;
    @Autowired
    Eighth_aMapper eighth_aMapper;
    @Autowired
    Eighth_bMapper eighth_bMapper;
    @Autowired
    Eighth_cMapper eighth_cMapper;
    @Autowired
    Ninth_messageMapper ninth_messageMapper;
    @Autowired
    Ninth_aMapper ninth_aMapper;
    @Autowired
    Ninth_bMapper ninth_bMapper;
    @Autowired
    Ninth_cMapper ninth_cMapper;
    @Autowired
    Tenth_messageMapper tenth_messageMapper;
    @Autowired
    Tenth_aMapper tenth_aMapper;
    @Autowired
    Tenth_bMapper tenth_bMapper;
    @Autowired
    Tenth_cMapper tenth_cMapper;
    @Autowired
    Eleventh_messageMapper eleventh_messageMapper;
    @Autowired
    Eleventh_aMapper eleventh_aMapper;


    public State LastFour_index(LastFourRequest request) {
        State temp = stateMapper.selectByName(request.getoName());
        if (temp == null) {
            State state = new State();
            state.setHospital(request.getoName());
            state.setA("0");
            state.setB("0");
            state.setC("0");
            state.setD("0");
            state.setE("0");
            state.setF("0");
            state.setG("0");
            stateMapper.insertSelective(state);
            return state;
        }else {
            return stateMapper.selectByName(request.getoName());
        }
    }


    private String[] a_c = {"高级职称","中级职称","初级职称","其他","合计"};
    private String[] a_h = {"年平均在职职工人数（人）","卫生技术人员","其他技术人员（人）","管理人员（人）","工勤技能人员 (人)","临时工（人）（选填）","在职职工年人均工资（万元/人）"};
    private String[] b_c = {"各级政府","国际组织","国际社会组织"};
    private String[] c_h = {"年度收费总额（元）","服务量（人次）","次均收费水平（元/人次）","卫生材料支出（元）","药品支出（元）","其他支出（元）"};

    public String Eighth_a(LastFourRequest request){
        Check_message("8_a",request);
             /*存入个人信息*/
        Eighth_message eighth_message = new Eighth_message();
        copyProperties
                (request,eighth_message);
        eighth_messageMapper.insertSelective(eighth_message);

       /*数据处理*/
        float[] temp =  new float[35];
        for(int i=0;i<35;i++){
            if (request.getEighthA()[i]!=""){
                temp[i] = Float.parseFloat(request.getEighthA()[i]);
            }
        }
        /*计算前五行的第一列合计*/
        for(int l=0;l<28;l=l+7){
            temp[l]=temp[l+1]+temp[l+2]+temp[l+3]+temp[l+4];
               /*新添加的验证，当人数不为0的时候，工资不能为0*/
            if(temp[l]!=0 || temp[l+5]!=0 ){
                if( temp[l+6]==0){
                    return "no";
                }
            }
        }
        /*计算第六行的前五列合计*/
        for(int i=0;i<6;i++){
            temp[i+28]=temp[i+7]+temp[i+14]+temp[i+21]+temp[i];
        }


        /*生成对象，存入数据库*/
        int num=0;
        List<Eighth_a> list = new ArrayList<Eighth_a>();
        for(int i=0;i<5;i++) {
            for (int j = 0; j < 7; j++) {
                Eighth_a eighth_a = new Eighth_a();
                eighth_a.setName(request.getoName());
                eighth_a.setType(a_c[i]);
                eighth_a.setcType(a_h[j]);
                eighth_a.setCount(String.valueOf(temp[num]));
                list.add(eighth_a);
                num=num+1;
            }

        }


        eighth_aMapper.insertBatch(list);
        Change_state("a",request.getoName());
        return "ok";
    }

    public String Eighth_b(LastFourRequest request){
        Check_message("8_b",request);
        float d_count=0F;//各级政府合计
        float d_count_two=0F;//国际及民间组织合计
        for(int i=1;i<32;i=i+2){
            if(request.getEighthB()[i]!=""){
                d_count=d_count+Float.parseFloat(request.getEighthB()[i]);
            }
        }
        for(int i=33;i<52;i=i+2){
            if(request.getEighthB()[i]!=""){
                d_count_two=d_count_two+Float.parseFloat(request.getEighthB()[i]);
            }
        }

        List<Eighth_b> list = new ArrayList<Eighth_b>();
        if(request.getEighthB()!=null){
            request.getEighthB()[1]=String.valueOf(d_count);
            for(int j=0;j<52;j=j+2){
                Eighth_b Eighth_b = new Eighth_b();
                Eighth_b.setHosptial(request.getoName());
                if(j<32){
                    Eighth_b.setSource(b_c[0]);
                }else if(j<42){
                    Eighth_b.setSource(b_c[1]);
                }else {
                    Eighth_b.setSource(b_c[2]);
                }
                Eighth_b.setProjectName(request.getEighthB()[j]);
                Eighth_b.setCount(request.getEighthB()[j+1]);
                list.add(Eighth_b);
            }
            /*添加民间及国际组织合计*/
            Eighth_b Eighth_b = new Eighth_b();
            Eighth_b.setHosptial(request.getoName());
            Eighth_b.setSource("民间及国际组织");
            Eighth_b.setProjectName("合计");
            Eighth_b.setCount(String.valueOf(d_count_two));
            list.add(Eighth_b);
            eighth_bMapper.insertBatch(list);
            Change_state("b",request.getoName());
        }
        return "ok";

    }

    public String Eighth_c(LastFourRequest request){
        Check_message("8_c",request);
        String [] all_eighth_c = new String[72];//字符串型的所有数据
        String[] all_out_c = new String [12];
        float[] c_f = new float[72];//浮点型的所有数据，汉字的部分默认0.0
        float[] new_out = new float[12];//新增的数据 支出情况
        for(int i = 0;i<72;i++){
            all_eighth_c[i]=request.getEighthC()[i];
            if((i%6)!=0 && all_eighth_c[i]!=""){c_f[i]=Float.parseFloat(all_eighth_c[i]);}
        }
        for(int w=1;w<12;w++){
            all_out_c[w]=request.getEighthCl()[w];
            if(all_out_c[w]!=null && all_out_c[w]!="" ){new_out[w]=Float.parseFloat(request.getEighthCl()[w]);}
        }
        /*计算必须项的合计数据*/

        /*计算第一列的合计*/
        for(int m=0;m<72;m=m+6){
            if(all_eighth_c[m]!=""){
                c_f[m+1]=c_f[m+2]*c_f[m+3];
            }
        }
          /*计算行的合计  包含了新增的支出列*/
        int[] start = {1};
        int[] round = {5};
        int[] out = {0};
        for(int i=0;i<1;i++){
            for(int j=0;j<5;j++){
                for(int k=0;k<round[i];k++){
                    c_f[start[i]+j]=c_f[start[i]+j]+c_f[(start[i]+j)+6*(k+1)];
                }
            }
            for(int m=0;m<round[i];m++){
                new_out[out[i]]=new_out[out[i]]+new_out[out[i]+m+1];
            }
        }

        /*转为字符串类型赋值给all_eighth_c*/
        for(int n=0;n<72;n++){
            if((n%6)!=0 && n<36){
                all_eighth_c[n]=String.valueOf(c_f[n]);
            }
            if(n>35&& (n%6)==0 && all_eighth_c[n]!=""){
                for(int p=1;p<6;p++){
                    all_eighth_c[n+p]=String.valueOf(c_f[n+p]);
                }
            }
            if(n<6){all_out_c[n]=String.valueOf(new_out[n]);}
        }
        all_eighth_c[2]="";
        all_eighth_c[3]="";

        /*将数据生成对象存储到数据库*/
        List<Eighth_c> list = new ArrayList<Eighth_c>();
        for(int i=0;i<72;i=i+6){
            for(int j=0;j<5;j++) {
                Eighth_c eighth_c = new Eighth_c();
                eighth_c.setType(all_eighth_c[i]);
                eighth_c.setHospital(request.getoName());
                eighth_c.setcType(c_h[j]);
                eighth_c.setCount(all_eighth_c[i+j+1]);
                list.add(eighth_c);
            }
            /*增加 支出列至list*/
            Eighth_c eighth_c = new Eighth_c();
            eighth_c.setType(all_eighth_c[i]);
            eighth_c.setHospital(request.getoName());
            eighth_c.setcType("其他支出（元）");
            eighth_c.setCount(String.valueOf(all_out_c[i/6]));
            list.add(eighth_c);
        }
        eighth_cMapper.insertBatch(list);
        Change_state("c",request.getoName());
        return "ok";
    }

    public String Ninth_a(LastFourRequest request){
        Check_message("9_a",request);
        /*存入个人信息*/
        Ninth_message ninth_message = new Ninth_message();
        copyProperties
                (request,ninth_message);
        ninth_messageMapper.insertSelective(ninth_message);

       /*数据处理*/
        float[] temp =  new float[35];
        for(int i=0;i<35;i++){
            if (request.getNinthA()[i]!=""){
                temp[i] = Float.parseFloat(request.getNinthA()[i]);
            }
        }
        /*计算前五行的第一列合计*/
        for(int l=0;l<28;l=l+7){
            temp[l]=temp[l+1]+temp[l+2]+temp[l+3]+temp[l+4];
               /*新添加的验证，当人数不为0的时候，工资不能为0*/
            if(temp[l]!=0 || temp[l+5]!=0 ){
                if( temp[l+6]==0){
                    return "no";
                }
            }
        }
        /*计算第六行的前五列合计*/
        for(int i=0;i<6;i++){
            temp[i+28]=temp[i+7]+temp[i+14]+temp[i+21]+temp[i];
        }


        /*生成对象，存入数据库*/
        int num=0;
        List<Ninth_a> list = new ArrayList<Ninth_a>();
        for(int i=0;i<5;i++) {
            for (int j = 0; j < 7; j++) {
                Ninth_a ninth_a = new Ninth_a();
                ninth_a.setName(request.getoName());
                ninth_a.setType(a_c[i]);
                ninth_a.setcType(a_h[j]);
                ninth_a.setCount(String.valueOf(temp[num]));
                list.add(ninth_a);
                num=num+1;
            }

        }


        ninth_aMapper.insertBatch(list);
        Change_state("a",request.getoName());
        return "ok";
    }

    public String Ninth_b(LastFourRequest request){
        Check_message("9_b",request);
        if(request.getNinthB()!=null) {
            request.getNinthB()[0] = "本机构财政项目支出补助收入";
        }
        /*数据处理*/
        float b_count=0F;
        for(int i=1;i<52;i=i+2){
            if(request.getNinthB()[i]!=""){
                b_count=b_count+Float.parseFloat(request.getNinthB()[i]);
            }
        }


        List<Ninth_b> list = new ArrayList<Ninth_b>();
        if(request.getNinthB()!=null){
            request.getNinthB()[1]=String.valueOf(b_count);
            for(int j=0;j<72;j=j+2){
                Ninth_b ninth_b = new Ninth_b();
                /*医院名称固定，由前一页传递过来*/
                ninth_b.setHosptial(request.getoName());
                if(j<52){
                    ninth_b.setSource(b_c[0]);
                }else if(j<62){
                    ninth_b.setSource(b_c[1]);
                }else {
                    ninth_b.setSource(b_c[2]);
                }
                ninth_b.setProjectName(request.getNinthB()[j]);
                ninth_b.setCount(request.getNinthB()[j+1]);
                list.add(ninth_b);
            }
            ninth_bMapper.insertBatch(list);
            Change_state("b",request.getoName());
        }
        return "ok";
    }

    public String Ninth_c(LastFourRequest request){
        Check_message("9_c",request);
        String [] all_ninth_c = new String[84];//字符串型的所有数据
        float[] c_f = new float[84];//浮点型的所有数据，汉字的部分默认0.0
        for(int i = 0;i<84;i++){
            all_ninth_c[i]=request.getNinthC()[i];
            if((i%6)!=0 && all_ninth_c[i]!=""){c_f[i]=Float.parseFloat(all_ninth_c[i]);}
        }
        /*计算必须项的合计数据*/

        /*计算第一列的合计*/
        for(int m=0;m<84;m=m+6){
            if(all_ninth_c[m]!=""){
                c_f[m+1]=c_f[m+2]*c_f[m+3];
            }
        }
        /*转为字符串类型赋值给all_ninth_c*/
        for(int n=0;n<84;n++){
            if((n%6)!=0 && n<24){
                all_ninth_c[n]=String.valueOf(c_f[n]);
            }
            if(n>23&& (n%6)==0 && all_ninth_c[n]!=""){
                for(int p=1;p<6;p++){
                    all_ninth_c[n+p]=String.valueOf(c_f[n+p]);
                }
            }
        }

        /*将数据生成对象存储到数据库*/
        List<Ninth_c> list = new ArrayList<Ninth_c>();
        for(int i=0;i<84;i=i+6){
            for(int j=0;j<5;j++) {
                Ninth_c ninth_c = new Ninth_c();
                ninth_c.setType(all_ninth_c[i]);
                ninth_c.setHospital(request.getoName());
                ninth_c.setDepartment(request.getNinthCdepartment());
                ninth_c.setcType(c_h[j]);
                ninth_c.setCount(all_ninth_c[i+j+1]);
                list.add(ninth_c);
            }
            /*增加 支出列至list*/
            Ninth_c ninth_c = new Ninth_c();
            ninth_c.setType(all_ninth_c[i]);
            ninth_c.setHospital(request.getoName());
            ninth_c.setDepartment(request.getNinthCdepartment());
            ninth_c.setcType("其他支出（元）");
            ninth_c.setCount(request.getNinthCl()[i/6]);
            list.add(ninth_c);
        }
        ninth_cMapper.insertBatch(list);
        Change_state("c",request.getoName());
        return "ok";
    }

    public String Tenth_a(LastFourRequest request){
        Check_message("10_a",request);
        Tenth_message tenth_message = new Tenth_message();
        copyProperties
                (request,tenth_message);
        tenth_messageMapper.insertSelective(tenth_message);

       /*数据处理*/
        float[] temp =  new float[35];
        for(int i=0;i<35;i++){
            if (request.getTenthA()[i]!=""){
                temp[i] = Float.parseFloat(request.getTenthA()[i]);
            }
        }
        /*计算前五行的第一列合计*/
        for(int l=0;l<28;l=l+7){
            temp[l]=temp[l+1]+temp[l+2]+temp[l+3]+temp[l+4];
               /*新添加的验证，当人数不为0的时候，工资不能为0*/
            if(temp[l]!=0 || temp[l+5]!=0 ){
                if( temp[l+6]==0){
                    return "no";
                }
            }
        }
        /*计算第六行的前五列合计*/
        for(int i=0;i<6;i++){
            temp[i+28]=temp[i+7]+temp[i+14]+temp[i+21]+temp[i];
        }


        /*生成对象，存入数据库*/
        int num=0;
        List<Tenth_a> list = new ArrayList<Tenth_a>();
        for(int i=0;i<5;i++) {
            for (int j = 0; j < 7; j++) {
                Tenth_a tenth_a = new Tenth_a();
                tenth_a.setName(request.getoName());
                tenth_a.setType(a_c[i]);
                tenth_a.setcType(a_h[j]);
                tenth_a.setCount(String.valueOf(temp[num]));
                list.add(tenth_a);
                num=num+1;
            }

        }

        tenth_aMapper.insertBatch(list);
        Change_state("a",request.getoName());
        return "ok";
    }

    public String Tenth_b(LastFourRequest request){
        Check_message("10_b",request);
        if(request.getTenthB()!=null) {
            request.getTenthB()[0] = "本机构财政项目支出补助收入";
        }
        /*数据处理*/
        float b_count=0F;
        for(int i=1;i<52;i=i+2){
            if(request.getTenthB()[i]!=""){
                b_count=b_count+Float.parseFloat(request.getTenthB()[i]);
            }
        }


        List<Tenth_b> list = new ArrayList<Tenth_b>();
        if(request.getTenthB()!=null){
            request.getTenthB()[1]=String.valueOf(b_count);
            for(int j=0;j<72;j=j+2){
                Tenth_b tenth_b = new Tenth_b();
                /*医院名称固定，由前一页传递过来*/
                tenth_b.setHosptial(request.getoName());
                if(j<52){
                    tenth_b.setSource(b_c[0]);
                }else if(j<62){
                    tenth_b.setSource(b_c[1]);
                }else {
                    tenth_b.setSource(b_c[2]);
                }
                tenth_b.setProjectName(request.getTenthB()[j]);
                tenth_b.setCount(request.getTenthB()[j+1]);
                list.add(tenth_b);
            }
            tenth_bMapper.insertBatch(list);
            Change_state("b",request.getoName());
        }
        return "ok";
    }

    public String Tenth_c(LastFourRequest request){
        Check_message("10_c",request);
        /*先把前台传过来的数据整合*/
        String [] all_tenth_c = new String[168];//字符串型的所有数据
        String[] all_out_c = new String [28];
        float[] c_f = new float[168];//浮点型的所有数据，汉字的部分默认0.0
        float[] new_out = new float[28];//新增的数据 支出情况
        float[] all_charge = new float[6];//收费总额，新加的第一行，=各大项之和
        for(int i = 0;i<168;i++){
            all_tenth_c[i]=request.getTenthC()[i];
            if((i%6)!=0 && all_tenth_c[i]!=""){c_f[i]=Float.parseFloat(all_tenth_c[i]);}
        }
        for(int w=1;w<28;w++){
            all_out_c[w]=request.getTenthCl()[w];
            if(all_out_c[w]!=null && all_out_c[w]!="" ){new_out[w]=Float.parseFloat(request.getTenthCl()[w]);}
        }
        /*计算必须项的合计数据*/

        /*计算第一列的合计*/
        for(int m=0;m<168;m=m+6){
            if(all_tenth_c[m]!=""){
                c_f[m+1]=c_f[m+2]*c_f[m+3];
            }
        }
        /*计算行的合计*/
        int[] start = {1,67,85};
        int[] round = {10,2,7};
        int[] out = {0,11,14};
        for(int i=0;i<3;i++){
            for(int j=0;j<5;j++){
                for(int k=0;k<round[i];k++){
                    c_f[start[i]+j]=c_f[start[i]+j]+c_f[(start[i]+j)+6*(k+1)];
                }
            }
            for(int m=0;m<round[i];m++){
                new_out[out[i]]=new_out[out[i]]+new_out[out[i]+m+1];
            }
        }
        /*计算全部公共卫生服务*/
        int[] to_charge = {1,67,85,133,139,145};
        int[] out_charge={0,11,14,22,23,24};
        for(int s=0;s<5;s++){
            for(int y=0;y<6;y++){
                all_charge[s]=all_charge[s]+c_f[to_charge[y]+s];
                if(s==0){
                    all_charge[5]=all_charge[5]+new_out[out_charge[y]];
                }
            }
        }
        /*转为字符串类型赋值给all_tenth_c*/
        for(int n=0;n<168;n++){
            if((n%6)!=0 && n<150){
                all_tenth_c[n]=String.valueOf(c_f[n]);
            }
            if(n>149&& (n%6)==0 && all_tenth_c[n]!=""){
                for(int p=1;p<6;p++){
                    all_tenth_c[n+p]=String.valueOf(c_f[n+p]);
                }
            }
            if(n<28){all_out_c[n]=String.valueOf(new_out[n]);}
        }
        for(int u=0;u<3;u++){
            all_tenth_c[start[u]+1]="";
        }
        for(int u=0;u<3;u++){
            all_tenth_c[start[u]+2]="";
        }

        /*将数据生成对象存储到数据库*/
        List<Tenth_c> list = new ArrayList<Tenth_c>();
        /*将全部公共卫生服务放入列表内*/
        for(int i=0;i<6;i++){
            Tenth_c tenth_c = new Tenth_c();
            tenth_c.setHospital(request.getoName());
            tenth_c.setType("全部计生技术服务");
            if(i==2){tenth_c.setCount("");}else{
                tenth_c.setCount(String.valueOf(all_charge[i]));
            }
            tenth_c.setcType(c_h[i]);
            list.add(tenth_c);
        }
        for(int i=0;i<168;i=i+6){
            for(int j=0;j<5;j++) {
                Tenth_c tenth_c = new Tenth_c();
                tenth_c.setType(all_tenth_c[i]);
                tenth_c.setHospital(request.getoName());
                tenth_c.setcType(c_h[j]);
                tenth_c.setCount(all_tenth_c[i+j+1]);
                list.add(tenth_c);
            }
             /*增加 支出列至list*/
            Tenth_c tenth_c = new Tenth_c();
            tenth_c.setType(all_tenth_c[i]);
            tenth_c.setHospital(request.getoName());
            tenth_c.setcType("其他支出（元）");
            tenth_c.setCount(String.valueOf(all_out_c[i/6]));
            list.add(tenth_c);
        }
        tenth_cMapper.insertBatch(list);
        Change_state("c",request.getoName());
        return "ok";
    }

    public String Eleventh_a(LastFourRequest request){
        Check_message("11",request);
        Eleventh_message eleventh_message = new Eleventh_message();
        copyProperties
                (request,eleventh_message);
        eleventh_messageMapper.insertSelective(eleventh_message);

        List<Eleventh_a> list = new ArrayList<>();
        for(int i=0;i<60;i=i+4){
            if(request.getEleventhA()!=null){
                Eleventh_a eleventh_a = new Eleventh_a();
                eleventh_a.setHospital(request.getoName());
                eleventh_a.setItem(request.getEleventhA()[i]);
                eleventh_a.setObject(request.getEleventhA()[i+1]);
                if(request.getEleventhA()[i+2]!=""){eleventh_a.setCount(request.getEleventhA()[i+2]);}
                else{eleventh_a.setCount("0");}
                if(request.getEleventhA()[i+3]!=""){eleventh_a.setPay(request.getEleventhA()[i+3]);}
                else{eleventh_a.setPay("0");}
                list.add(eleventh_a);

            }
        }
        eleventh_aMapper.insertBatch(list);
        Change_state("a",request.getoName());
        return "ok";
    }


    public String Check_message(String table,LastFourRequest request){
        switch (table)
        {
            case "8_a":
                if(eighth_aMapper.selectByName(request.getoName())!=null){
                    eighth_aMapper.deleteByName(request.getoName());
                }
                break;
            case "8_b":
                if(eighth_bMapper.selectByName(request.getoName())!=null){
                    eighth_bMapper.deleteByName(request.getoName());
                }
                break;
            case "8_c":
                if(eighth_cMapper.selectByName(request.getoName())!=null){
                    eighth_cMapper.deleteByName(request.getoName());
                }
                break;
            case "9_a":
                if(ninth_aMapper.selectByName(request.getoName())!=null){
                    ninth_aMapper.deleteByName(request.getoName());
                }
                break;
            case "9_b":
                if(ninth_bMapper.selectByName(request.getoName())!=null){
                    ninth_bMapper.deleteByName(request.getoName());
                }
                break;
            case "9_c":
                Ninth_c ninth_c = new Ninth_c();
                ninth_c.setHospital(request.getoName());
                ninth_c.setDepartment(request.getNinthCdepartment());
                if(ninth_cMapper.selectByName(ninth_c)!=null){
                    ninth_cMapper.deleteByName(ninth_c);
                }
                break;
            case "10_a":
                if(tenth_aMapper.selectByName(request.getoName())!=null){
                    tenth_aMapper.deleteByName(request.getoName());
                }
                break;
            case "10_b":
                if(tenth_bMapper.selectByName(request.getoName())!=null){
                    tenth_bMapper.deleteByName(request.getoName());
                }
                break;
            case "10_c":
                if(tenth_cMapper.selectByName(request.getoName())!=null){
                    tenth_cMapper.deleteByName(request.getoName());
                }
                break;
            case "11":
                if(eleventh_aMapper.selectByName(request.getoName())!=null){
                    eleventh_aMapper.deleteByName(request.getoName());
                }
                break;
        }

        return "ok";
    }





    private String Change_state(String table,String oName) {
        State state = stateMapper.selectByName(oName);
        switch (table)
        {
            case "a":
                state.setA("1");
                break;
            case "b":
                state.setB("1");
                break;
            case "c":
                state.setC("1");
                break;
            case "d":
                state.setD("1");
                break;
            case "e":
                state.setE("1");
                break;
            case "f":
                state.setF("1");
                break;
            case "g":
                state.setG("1");
                break;
        }
        stateMapper.updateByName(state);
        return "ok";
    }




}
